﻿Namespace Forms
    Public Class NoFocusForm
        Inherits Form

        Private Const WS_EX_NOACTIVATE As Integer = &H8000000
        Private Const WM_MOUSEACTIVATE As Integer = &H21
        Private Const MA_NOACTIVATE As Integer = &H3

        Protected Overrides ReadOnly Property CreateParams As CreateParams
            Get
                CreateParams = MyBase.CreateParams
                CreateParams.ExStyle = CreateParams.ExStyle And WS_EX_NOACTIVATE
                Return CreateParams
            End Get
        End Property

        Protected Overrides Sub WndProc(ByRef m As Message)
            If m.Msg = WM_MOUSEACTIVATE Then
                m.Result = MA_NOACTIVATE
            Else
                MyBase.WndProc(m)
            End If
        End Sub
    End Class
End Namespace